package xyz.jangle.io;

import java.util.Scanner;
/**
 * 参考文献：https://www.runoob.com/java/java-scanner-class.html
 * next方法和nextLine方法的区别
 * next方法会将空格作为分隔符，而nextLine是以回车作为分隔符。
 * @author Administrator
 *
 */
public class ScannerMain {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		// 从键盘接收数据
//		test1(scan);
		test2(scan);
		// next方式接收字符串

		scan.close();

	}

	@SuppressWarnings("unused")
	private static void test1(Scanner scan) {
		while (scan.hasNext()) {
			String str1 = scan.next();
			System.out.println("输入的数据为：" + str1);
			if (str1.equals("end")) {
				break;
			}
		}
	}

	private static void test2(Scanner scan) {
		while (scan.hasNextLine()) {
			String str2 = scan.nextLine();
			System.out.println("输入的数据为：" + str2);
			if (str2.equals("end")) {
				break;
			}
		}
	}

}
